Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement v2 RecvPacket rpc handler #7421

Open
wants to merge 15 commits into
base: feat/ibc-eureka
Choose a base branch
from

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Oct 9, 2024

Description

closes: #7354


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@chatton chatton changed the title [WIP DONT REVIEW] Implement v2 RecvPacket rpc handler Implement v2 RecvPacket rpc handler Oct 10, 2024
@chatton chatton marked this pull request as ready for review October 10, 2024 12:17
return errorsmod.Wrap(channeltypes.ErrInvalidPacket, "receipt not found for packet")
}

multiAckBz := k.cdc.MustMarshal(&ack)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to ackBz

newAttributes[j] = sdk.NewAttribute(coretypes.ErrorAttributeKeyPrefix+attribute.Key, attribute.Value)
}

newEvents[i] = sdk.NewEvent(coretypes.ErrorAttributeKeyPrefix+event.Type, newAttributes...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can avoid having the newAttributes slice if we do

	newEvents := make(sdk.Events, len(events))
	for i, event := range events {
		newEvents[i] = sdk.NewEvent(coretypes.ErrorAttributeKeyPrefix+event.Type)
		for _, attribute := range event.Attributes {
                        newEvents[i].AppendAttributes(sdk.NewAttribute(coretypes.ErrorAttributeKeyPrefix+attribute.Key, attribute.Value))
		}

	}

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was just copy pasted from the existing fn in v1 msg_server.go, I'll create another issue to remove the duplication, and maybe we can make these changes here? I'll link this comment in the issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sure no big deal!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 257 to 261
suite.Require().Contains(err.Error(), tc.expError.Error())

_, ok := ck.GetPacketReceipt(path.EndpointB.Chain.GetContext(), recvPacket.SourceChannel, recvPacket.Sequence)
suite.Require().False(ok)
ibctesting.RequireErrorIsOrContains(suite.T(), err, tc.expError)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't line 261 be at 257 (and the current 257 can be removed?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge conflict mistake I think, will fix!

packet channeltypesv2.Packet,
ack channeltypesv2.Acknowledgement,
) error {
// Lookup channel associated with our source channel to retrieve the destination channel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't source and destination be swapped here? Given that below we use DestinationChannel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def can do with some retouching, I think the one for recv can be reused here just fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we meant the same thing, I meant in the comment anyway :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah think comment was from a copy pasta, will fix, nice catch

Copy link
Contributor

@bznein bznein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -92,18 +101,66 @@ func (k *Keeper) RecvPacket(ctx context.Context, msg *channeltypesv2.MsgRecvPack
return nil, errorsmod.Wrap(err, "invalid address for msg Signer")
}

_ = signer
switch err {
case nil:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed one thing: this case can never be true, since we check for err != nil above. I believe this is supposed to be a different err (the one at line 92? But in that case we still don't need this case)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really nice catch! Also highlights the missing NoOp case, I'll push a fix for this

Copy link

sonarcloud bot commented Oct 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants